﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HotelManagement.DAO;
using HotelManagement.DTO;

namespace HotelManagement.BLO
{
    class RoomBLO
    {
        private RoomDAO dao;
        

        public RoomDAO Dao
        {
            get { return dao; }
            set { dao = value; }
        }
        public RoomBLO()
        {
            dao = new RoomDAO();
            
        }

        public bool Insert(RoomDTO room)
        {
            return dao.Insert(room);
        }

        public bool UpdateInfo(RoomDTO room)
        {
            return dao.UpdateInfo(room);
        }
        public DataTable SelectAllWithTypeName()
        {
            return dao.SelectAllWithTypeName();
        }

        public int SelectLastInsertID()
        {
            return dao.SelectLastInsertID();
        }
        public DataTable Select()
        {
            return dao.Select();
        }
        public int GetIDFromName(string pRoomName)
        {
            if (pRoomName=="")
            {
                return 0;
            }
            DataTable tbl = this.Select();
            foreach(DataRow row in tbl.Rows)
            {
                if (row["RoomName"].ToString()==pRoomName)
                {
                    return int.Parse(row["RoomID"].ToString());

                }
            }
            return 0;
        }

        public string GetStatusNameFromStatusID(int pStatusID)
        {
            CheckInput chk = new CheckInput();
            return HotelManagement.CheckInput.lstStatus[pStatusID];
        }
        public int GetStatusIDFromStatusName(string pStatusName)
        {
            return HotelManagement.CheckInput.lstStatus.IndexOf(pStatusName);
        }
        public bool UpdateWhenRent(RoomDTO room)
        {
            return dao.UpdateWhenRent(room);
        }
        public RoomDTO SelectRoomFromID(int pID)
        {
            return dao.SelectRoomFromID(pID);
        }

    }
}
